function include(filename)
{
	var head = document.getElementsByTagName('head')[0];
	
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	
	head.appendChild(script)
}

//include('http://www.google.com/jsapi?key=ABQIAAAAwbkbZLyhsmTCWXbTcjbgbRSzHs7K5SvaUdm8ua-Xxy_-2dYwMxQMhnagaawTo7L1FE1-amhuQxIlXw');
include('math3d.js');
include('milktruck.js');

google.load("earth", "1");
google.load("maps", "2.99");

var ge = null;
var geocoder;
var truck;

function el(e) { return document.getElementById(e); }

function Sample(description, url) {
  this.description = description;
  this.url = url;
  return this;
}

var samples = [];

function init() {
  geocoder = new GClientGeocoder();

  init3D();
}

function initCallback(object) {
  ge = object;
  ge.getWindow().setVisibility(true);
  ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
  ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);

  truck = new Truck();
}

function failureCallback(err) {
  /***
   * This function will be called if plugin fails to load, in case
   * you need to handle that error condition.
   ***/
}

function init3D() {
  google.earth.createInstance("map3d", initCallback, failureCallback);
}

function submitLocation() {
  doGeocode(el('address').value);
}

function doGeocode(address) {
  geocoder.getLatLng(address, function(point) {
    if (point) {
      if (ge != null && truck != null) {
        truck.teleportTo(point.y, point.x);
      }
    }
  });
}

google.load("earth", "1");
google.load("maps", "2.99");

var ge = null;
var geocoder;
var truck;

function el(e) { return document.getElementById(e); }

function Sample(description, url) {
  this.description = description;
  this.url = url;
  return this;
}

var samples = [];

// SO DIRTY!!!!
function pause(millis) {
  var date = new Date();
  var curDate = null;
  do { curDate = new Date(); }
  while(curDate-date < millis);
}

function init() {
  geocoder = new GClientGeocoder();

  init3D();
}


function initCallback(object) {
  ge = object;
  ge.getWindow().setVisibility(true);
  ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
  ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);

  truck = new Truck();
}

function failureCallback(err) {
  /***
   * This function will be called if plugin fails to load, in case
   * you need to handle that error condition.
   ***/
}

function init3D() {
  google.earth.createInstance("map3d", initCallback, failureCallback);
}

function submitLocation() {
  doGeocode(el('address').value);
}

function doGeocode(address) {
  geocoder.getLatLng(address, function(point) {
    if (point) {
      if (ge != null && truck != null) {
        truck.teleportTo(point.y, point.x);
      }
    }
  });
}

<!-- CCP WRAPPERS -->

function InitializeWorld() {
  init();
}

addr_ = "";

function tt_impl() {
  doGeocode(addr_);
}

function TeleportTo(address) {
  //while (truck == null) {}
  //doGeocode(address);
  addr_ = address;
  setTimeout("tt_impl()", 5000);
}

new_model_url_ = "";

function sm_impl() {
  alert(1);
  window.google.earth.fetchKml(ge, new_model_url_,
                               function(obj) { window.truck.finishInit(obj); });
} 

function SetModel(new_model_url) {
  new_model_url_ = new_model_url;
  setTimeout("sm_impl()", 5000);
}
